package com.xjgzinfo.usdp.web.rest;

import com.xjgzinfo.usdp.AvueServer4jApp;
import com.xjgzinfo.usdp.config.TestSecurityConfiguration;
import com.xjgzinfo.usdp.domain.TemplateScoreRecord;
import com.xjgzinfo.usdp.domain.TemplateMarket;
import com.xjgzinfo.usdp.repository.TemplateScoreRecordRepository;
import com.xjgzinfo.usdp.service.TemplateScoreRecordService;
import com.xjgzinfo.usdp.service.dto.TemplateScoreRecordDTO;
import com.xjgzinfo.usdp.service.mapper.TemplateScoreRecordMapper;
import com.xjgzinfo.usdp.service.dto.TemplateScoreRecordCriteria;
import com.xjgzinfo.usdp.service.TemplateScoreRecordQueryService;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

/**
 * Integration tests for the {@link TemplateScoreRecordResource} REST controller.
 */
@SpringBootTest(classes = { AvueServer4jApp.class, TestSecurityConfiguration.class })
@AutoConfigureMockMvc
@WithMockUser
public class TemplateScoreRecordResourceIT {

    private static final Long DEFAULT_RECORD_ID = 1L;
    private static final Long UPDATED_RECORD_ID = 2L;
    private static final Long SMALLER_RECORD_ID = 1L - 1L;

    private static final Long DEFAULT_TEMPLATE_ID = 1L;
    private static final Long UPDATED_TEMPLATE_ID = 2L;
    private static final Long SMALLER_TEMPLATE_ID = 1L - 1L;

    private static final Double DEFAULT_SCORE = 1D;
    private static final Double UPDATED_SCORE = 2D;
    private static final Double SMALLER_SCORE = 1D - 1D;

    private static final String DEFAULT_CREATE_USER = "AAAAAAAAAA";
    private static final String UPDATED_CREATE_USER = "BBBBBBBBBB";

    private static final Instant DEFAULT_CREATE_TIME = Instant.ofEpochMilli(0L);
    private static final Instant UPDATED_CREATE_TIME = Instant.now().truncatedTo(ChronoUnit.MILLIS);

    private static final String DEFAULT_ORIGIN_TYPE = "AAAAAAAAAA";
    private static final String UPDATED_ORIGIN_TYPE = "BBBBBBBBBB";

    private static final String DEFAULT_COMMENT = "AAAAAAAAAA";
    private static final String UPDATED_COMMENT = "BBBBBBBBBB";

    private static final String DEFAULT_TAGS = "AAAAAAAAAA";
    private static final String UPDATED_TAGS = "BBBBBBBBBB";

    @Autowired
    private TemplateScoreRecordRepository templateScoreRecordRepository;

    @Autowired
    private TemplateScoreRecordMapper templateScoreRecordMapper;

    @Autowired
    private TemplateScoreRecordService templateScoreRecordService;

    @Autowired
    private TemplateScoreRecordQueryService templateScoreRecordQueryService;

    @Autowired
    private EntityManager em;

    @Autowired
    private MockMvc restTemplateScoreRecordMockMvc;

    private TemplateScoreRecord templateScoreRecord;

    /**
     * Create an entity for this test.
     *
     * This is a static method, as tests for other entities might also need it,
     * if they test an entity which requires the current entity.
     */
    public static TemplateScoreRecord createEntity(EntityManager em) {
        TemplateScoreRecord templateScoreRecord = new TemplateScoreRecord()
            .recordId(DEFAULT_RECORD_ID)
            .templateId(DEFAULT_TEMPLATE_ID)
            .score(DEFAULT_SCORE)
            .createUser(DEFAULT_CREATE_USER)
            .createTime(DEFAULT_CREATE_TIME)
            .originType(DEFAULT_ORIGIN_TYPE)
            .comment(DEFAULT_COMMENT)
            .tags(DEFAULT_TAGS);
        return templateScoreRecord;
    }
    /**
     * Create an updated entity for this test.
     *
     * This is a static method, as tests for other entities might also need it,
     * if they test an entity which requires the current entity.
     */
    public static TemplateScoreRecord createUpdatedEntity(EntityManager em) {
        TemplateScoreRecord templateScoreRecord = new TemplateScoreRecord()
            .recordId(UPDATED_RECORD_ID)
            .templateId(UPDATED_TEMPLATE_ID)
            .score(UPDATED_SCORE)
            .createUser(UPDATED_CREATE_USER)
            .createTime(UPDATED_CREATE_TIME)
            .originType(UPDATED_ORIGIN_TYPE)
            .comment(UPDATED_COMMENT)
            .tags(UPDATED_TAGS);
        return templateScoreRecord;
    }

    @BeforeEach
    public void initTest() {
        templateScoreRecord = createEntity(em);
    }

    @Test
    @Transactional
    public void createTemplateScoreRecord() throws Exception {
        int databaseSizeBeforeCreate = templateScoreRecordRepository.findAll().size();
        // Create the TemplateScoreRecord
        TemplateScoreRecordDTO templateScoreRecordDTO = templateScoreRecordMapper.toDto(templateScoreRecord);
        restTemplateScoreRecordMockMvc.perform(post("/api/template-score-records").with(csrf())
            .contentType(MediaType.APPLICATION_JSON)
            .content(TestUtil.convertObjectToJsonBytes(templateScoreRecordDTO)))
            .andExpect(status().isCreated());

        // Validate the TemplateScoreRecord in the database
        List<TemplateScoreRecord> templateScoreRecordList = templateScoreRecordRepository.findAll();
        assertThat(templateScoreRecordList).hasSize(databaseSizeBeforeCreate + 1);
        TemplateScoreRecord testTemplateScoreRecord = templateScoreRecordList.get(templateScoreRecordList.size() - 1);
        assertThat(testTemplateScoreRecord.getRecordId()).isEqualTo(DEFAULT_RECORD_ID);
        assertThat(testTemplateScoreRecord.getTemplateId()).isEqualTo(DEFAULT_TEMPLATE_ID);
        assertThat(testTemplateScoreRecord.getScore()).isEqualTo(DEFAULT_SCORE);
        assertThat(testTemplateScoreRecord.getCreateUser()).isEqualTo(DEFAULT_CREATE_USER);
        assertThat(testTemplateScoreRecord.getCreateTime()).isEqualTo(DEFAULT_CREATE_TIME);
        assertThat(testTemplateScoreRecord.getOriginType()).isEqualTo(DEFAULT_ORIGIN_TYPE);
        assertThat(testTemplateScoreRecord.getComment()).isEqualTo(DEFAULT_COMMENT);
        assertThat(testTemplateScoreRecord.getTags()).isEqualTo(DEFAULT_TAGS);
    }

    @Test
    @Transactional
    public void createTemplateScoreRecordWithExistingId() throws Exception {
        int databaseSizeBeforeCreate = templateScoreRecordRepository.findAll().size();

        // Create the TemplateScoreRecord with an existing ID
        templateScoreRecord.setId(1L);
        TemplateScoreRecordDTO templateScoreRecordDTO = templateScoreRecordMapper.toDto(templateScoreRecord);

        // An entity with an existing ID cannot be created, so this API call must fail
        restTemplateScoreRecordMockMvc.perform(post("/api/template-score-records").with(csrf())
            .contentType(MediaType.APPLICATION_JSON)
            .content(TestUtil.convertObjectToJsonBytes(templateScoreRecordDTO)))
            .andExpect(status().isBadRequest());

        // Validate the TemplateScoreRecord in the database
        List<TemplateScoreRecord> templateScoreRecordList = templateScoreRecordRepository.findAll();
        assertThat(templateScoreRecordList).hasSize(databaseSizeBeforeCreate);
    }


    @Test
    @Transactional
    public void checkRecordIdIsRequired() throws Exception {
        int databaseSizeBeforeTest = templateScoreRecordRepository.findAll().size();
        // set the field null
        templateScoreRecord.setRecordId(null);

        // Create the TemplateScoreRecord, which fails.
        TemplateScoreRecordDTO templateScoreRecordDTO = templateScoreRecordMapper.toDto(templateScoreRecord);


        restTemplateScoreRecordMockMvc.perform(post("/api/template-score-records").with(csrf())
            .contentType(MediaType.APPLICATION_JSON)
            .content(TestUtil.convertObjectToJsonBytes(templateScoreRecordDTO)))
            .andExpect(status().isBadRequest());

        List<TemplateScoreRecord> templateScoreRecordList = templateScoreRecordRepository.findAll();
        assertThat(templateScoreRecordList).hasSize(databaseSizeBeforeTest);
    }

    @Test
    @Transactional
    public void checkTemplateIdIsRequired() throws Exception {
        int databaseSizeBeforeTest = templateScoreRecordRepository.findAll().size();
        // set the field null
        templateScoreRecord.setTemplateId(null);

        // Create the TemplateScoreRecord, which fails.
        TemplateScoreRecordDTO templateScoreRecordDTO = templateScoreRecordMapper.toDto(templateScoreRecord);


        restTemplateScoreRecordMockMvc.perform(post("/api/template-score-records").with(csrf())
            .contentType(MediaType.APPLICATION_JSON)
            .content(TestUtil.convertObjectToJsonBytes(templateScoreRecordDTO)))
            .andExpect(status().isBadRequest());

        List<TemplateScoreRecord> templateScoreRecordList = templateScoreRecordRepository.findAll();
        assertThat(templateScoreRecordList).hasSize(databaseSizeBeforeTest);
    }

    @Test
    @Transactional
    public void checkScoreIsRequired() throws Exception {
        int databaseSizeBeforeTest = templateScoreRecordRepository.findAll().size();
        // set the field null
        templateScoreRecord.setScore(null);

        // Create the TemplateScoreRecord, which fails.
        TemplateScoreRecordDTO templateScoreRecordDTO = templateScoreRecordMapper.toDto(templateScoreRecord);


        restTemplateScoreRecordMockMvc.perform(post("/api/template-score-records").with(csrf())
            .contentType(MediaType.APPLICATION_JSON)
            .content(TestUtil.convertObjectToJsonBytes(templateScoreRecordDTO)))
            .andExpect(status().isBadRequest());

        List<TemplateScoreRecord> templateScoreRecordList = templateScoreRecordRepository.findAll();
        assertThat(templateScoreRecordList).hasSize(databaseSizeBeforeTest);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecords() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList
        restTemplateScoreRecordMockMvc.perform(get("/api/template-score-records?sort=id,desc"))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$.[*].id").value(hasItem(templateScoreRecord.getId().intValue())))
            .andExpect(jsonPath("$.[*].recordId").value(hasItem(DEFAULT_RECORD_ID.intValue())))
            .andExpect(jsonPath("$.[*].templateId").value(hasItem(DEFAULT_TEMPLATE_ID.intValue())))
            .andExpect(jsonPath("$.[*].score").value(hasItem(DEFAULT_SCORE.doubleValue())))
            .andExpect(jsonPath("$.[*].createUser").value(hasItem(DEFAULT_CREATE_USER)))
            .andExpect(jsonPath("$.[*].createTime").value(hasItem(DEFAULT_CREATE_TIME.toString())))
            .andExpect(jsonPath("$.[*].originType").value(hasItem(DEFAULT_ORIGIN_TYPE)))
            .andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT)))
            .andExpect(jsonPath("$.[*].tags").value(hasItem(DEFAULT_TAGS)));
    }
    
    @Test
    @Transactional
    public void getTemplateScoreRecord() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get the templateScoreRecord
        restTemplateScoreRecordMockMvc.perform(get("/api/template-score-records/{id}", templateScoreRecord.getId()))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$.id").value(templateScoreRecord.getId().intValue()))
            .andExpect(jsonPath("$.recordId").value(DEFAULT_RECORD_ID.intValue()))
            .andExpect(jsonPath("$.templateId").value(DEFAULT_TEMPLATE_ID.intValue()))
            .andExpect(jsonPath("$.score").value(DEFAULT_SCORE.doubleValue()))
            .andExpect(jsonPath("$.createUser").value(DEFAULT_CREATE_USER))
            .andExpect(jsonPath("$.createTime").value(DEFAULT_CREATE_TIME.toString()))
            .andExpect(jsonPath("$.originType").value(DEFAULT_ORIGIN_TYPE))
            .andExpect(jsonPath("$.comment").value(DEFAULT_COMMENT))
            .andExpect(jsonPath("$.tags").value(DEFAULT_TAGS));
    }


    @Test
    @Transactional
    public void getTemplateScoreRecordsByIdFiltering() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        Long id = templateScoreRecord.getId();

        defaultTemplateScoreRecordShouldBeFound("id.equals=" + id);
        defaultTemplateScoreRecordShouldNotBeFound("id.notEquals=" + id);

        defaultTemplateScoreRecordShouldBeFound("id.greaterThanOrEqual=" + id);
        defaultTemplateScoreRecordShouldNotBeFound("id.greaterThan=" + id);

        defaultTemplateScoreRecordShouldBeFound("id.lessThanOrEqual=" + id);
        defaultTemplateScoreRecordShouldNotBeFound("id.lessThan=" + id);
    }


    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByRecordIdIsEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where recordId equals to DEFAULT_RECORD_ID
        defaultTemplateScoreRecordShouldBeFound("recordId.equals=" + DEFAULT_RECORD_ID);

        // Get all the templateScoreRecordList where recordId equals to UPDATED_RECORD_ID
        defaultTemplateScoreRecordShouldNotBeFound("recordId.equals=" + UPDATED_RECORD_ID);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByRecordIdIsNotEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where recordId not equals to DEFAULT_RECORD_ID
        defaultTemplateScoreRecordShouldNotBeFound("recordId.notEquals=" + DEFAULT_RECORD_ID);

        // Get all the templateScoreRecordList where recordId not equals to UPDATED_RECORD_ID
        defaultTemplateScoreRecordShouldBeFound("recordId.notEquals=" + UPDATED_RECORD_ID);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByRecordIdIsInShouldWork() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where recordId in DEFAULT_RECORD_ID or UPDATED_RECORD_ID
        defaultTemplateScoreRecordShouldBeFound("recordId.in=" + DEFAULT_RECORD_ID + "," + UPDATED_RECORD_ID);

        // Get all the templateScoreRecordList where recordId equals to UPDATED_RECORD_ID
        defaultTemplateScoreRecordShouldNotBeFound("recordId.in=" + UPDATED_RECORD_ID);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByRecordIdIsNullOrNotNull() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where recordId is not null
        defaultTemplateScoreRecordShouldBeFound("recordId.specified=true");

        // Get all the templateScoreRecordList where recordId is null
        defaultTemplateScoreRecordShouldNotBeFound("recordId.specified=false");
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByRecordIdIsGreaterThanOrEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where recordId is greater than or equal to DEFAULT_RECORD_ID
        defaultTemplateScoreRecordShouldBeFound("recordId.greaterThanOrEqual=" + DEFAULT_RECORD_ID);

        // Get all the templateScoreRecordList where recordId is greater than or equal to UPDATED_RECORD_ID
        defaultTemplateScoreRecordShouldNotBeFound("recordId.greaterThanOrEqual=" + UPDATED_RECORD_ID);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByRecordIdIsLessThanOrEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where recordId is less than or equal to DEFAULT_RECORD_ID
        defaultTemplateScoreRecordShouldBeFound("recordId.lessThanOrEqual=" + DEFAULT_RECORD_ID);

        // Get all the templateScoreRecordList where recordId is less than or equal to SMALLER_RECORD_ID
        defaultTemplateScoreRecordShouldNotBeFound("recordId.lessThanOrEqual=" + SMALLER_RECORD_ID);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByRecordIdIsLessThanSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where recordId is less than DEFAULT_RECORD_ID
        defaultTemplateScoreRecordShouldNotBeFound("recordId.lessThan=" + DEFAULT_RECORD_ID);

        // Get all the templateScoreRecordList where recordId is less than UPDATED_RECORD_ID
        defaultTemplateScoreRecordShouldBeFound("recordId.lessThan=" + UPDATED_RECORD_ID);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByRecordIdIsGreaterThanSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where recordId is greater than DEFAULT_RECORD_ID
        defaultTemplateScoreRecordShouldNotBeFound("recordId.greaterThan=" + DEFAULT_RECORD_ID);

        // Get all the templateScoreRecordList where recordId is greater than SMALLER_RECORD_ID
        defaultTemplateScoreRecordShouldBeFound("recordId.greaterThan=" + SMALLER_RECORD_ID);
    }


    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTemplateIdIsEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where templateId equals to DEFAULT_TEMPLATE_ID
        defaultTemplateScoreRecordShouldBeFound("templateId.equals=" + DEFAULT_TEMPLATE_ID);

        // Get all the templateScoreRecordList where templateId equals to UPDATED_TEMPLATE_ID
        defaultTemplateScoreRecordShouldNotBeFound("templateId.equals=" + UPDATED_TEMPLATE_ID);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTemplateIdIsNotEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where templateId not equals to DEFAULT_TEMPLATE_ID
        defaultTemplateScoreRecordShouldNotBeFound("templateId.notEquals=" + DEFAULT_TEMPLATE_ID);

        // Get all the templateScoreRecordList where templateId not equals to UPDATED_TEMPLATE_ID
        defaultTemplateScoreRecordShouldBeFound("templateId.notEquals=" + UPDATED_TEMPLATE_ID);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTemplateIdIsInShouldWork() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where templateId in DEFAULT_TEMPLATE_ID or UPDATED_TEMPLATE_ID
        defaultTemplateScoreRecordShouldBeFound("templateId.in=" + DEFAULT_TEMPLATE_ID + "," + UPDATED_TEMPLATE_ID);

        // Get all the templateScoreRecordList where templateId equals to UPDATED_TEMPLATE_ID
        defaultTemplateScoreRecordShouldNotBeFound("templateId.in=" + UPDATED_TEMPLATE_ID);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTemplateIdIsNullOrNotNull() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where templateId is not null
        defaultTemplateScoreRecordShouldBeFound("templateId.specified=true");

        // Get all the templateScoreRecordList where templateId is null
        defaultTemplateScoreRecordShouldNotBeFound("templateId.specified=false");
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTemplateIdIsGreaterThanOrEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where templateId is greater than or equal to DEFAULT_TEMPLATE_ID
        defaultTemplateScoreRecordShouldBeFound("templateId.greaterThanOrEqual=" + DEFAULT_TEMPLATE_ID);

        // Get all the templateScoreRecordList where templateId is greater than or equal to UPDATED_TEMPLATE_ID
        defaultTemplateScoreRecordShouldNotBeFound("templateId.greaterThanOrEqual=" + UPDATED_TEMPLATE_ID);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTemplateIdIsLessThanOrEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where templateId is less than or equal to DEFAULT_TEMPLATE_ID
        defaultTemplateScoreRecordShouldBeFound("templateId.lessThanOrEqual=" + DEFAULT_TEMPLATE_ID);

        // Get all the templateScoreRecordList where templateId is less than or equal to SMALLER_TEMPLATE_ID
        defaultTemplateScoreRecordShouldNotBeFound("templateId.lessThanOrEqual=" + SMALLER_TEMPLATE_ID);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTemplateIdIsLessThanSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where templateId is less than DEFAULT_TEMPLATE_ID
        defaultTemplateScoreRecordShouldNotBeFound("templateId.lessThan=" + DEFAULT_TEMPLATE_ID);

        // Get all the templateScoreRecordList where templateId is less than UPDATED_TEMPLATE_ID
        defaultTemplateScoreRecordShouldBeFound("templateId.lessThan=" + UPDATED_TEMPLATE_ID);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTemplateIdIsGreaterThanSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where templateId is greater than DEFAULT_TEMPLATE_ID
        defaultTemplateScoreRecordShouldNotBeFound("templateId.greaterThan=" + DEFAULT_TEMPLATE_ID);

        // Get all the templateScoreRecordList where templateId is greater than SMALLER_TEMPLATE_ID
        defaultTemplateScoreRecordShouldBeFound("templateId.greaterThan=" + SMALLER_TEMPLATE_ID);
    }


    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByScoreIsEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where score equals to DEFAULT_SCORE
        defaultTemplateScoreRecordShouldBeFound("score.equals=" + DEFAULT_SCORE);

        // Get all the templateScoreRecordList where score equals to UPDATED_SCORE
        defaultTemplateScoreRecordShouldNotBeFound("score.equals=" + UPDATED_SCORE);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByScoreIsNotEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where score not equals to DEFAULT_SCORE
        defaultTemplateScoreRecordShouldNotBeFound("score.notEquals=" + DEFAULT_SCORE);

        // Get all the templateScoreRecordList where score not equals to UPDATED_SCORE
        defaultTemplateScoreRecordShouldBeFound("score.notEquals=" + UPDATED_SCORE);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByScoreIsInShouldWork() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where score in DEFAULT_SCORE or UPDATED_SCORE
        defaultTemplateScoreRecordShouldBeFound("score.in=" + DEFAULT_SCORE + "," + UPDATED_SCORE);

        // Get all the templateScoreRecordList where score equals to UPDATED_SCORE
        defaultTemplateScoreRecordShouldNotBeFound("score.in=" + UPDATED_SCORE);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByScoreIsNullOrNotNull() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where score is not null
        defaultTemplateScoreRecordShouldBeFound("score.specified=true");

        // Get all the templateScoreRecordList where score is null
        defaultTemplateScoreRecordShouldNotBeFound("score.specified=false");
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByScoreIsGreaterThanOrEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where score is greater than or equal to DEFAULT_SCORE
        defaultTemplateScoreRecordShouldBeFound("score.greaterThanOrEqual=" + DEFAULT_SCORE);

        // Get all the templateScoreRecordList where score is greater than or equal to UPDATED_SCORE
        defaultTemplateScoreRecordShouldNotBeFound("score.greaterThanOrEqual=" + UPDATED_SCORE);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByScoreIsLessThanOrEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where score is less than or equal to DEFAULT_SCORE
        defaultTemplateScoreRecordShouldBeFound("score.lessThanOrEqual=" + DEFAULT_SCORE);

        // Get all the templateScoreRecordList where score is less than or equal to SMALLER_SCORE
        defaultTemplateScoreRecordShouldNotBeFound("score.lessThanOrEqual=" + SMALLER_SCORE);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByScoreIsLessThanSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where score is less than DEFAULT_SCORE
        defaultTemplateScoreRecordShouldNotBeFound("score.lessThan=" + DEFAULT_SCORE);

        // Get all the templateScoreRecordList where score is less than UPDATED_SCORE
        defaultTemplateScoreRecordShouldBeFound("score.lessThan=" + UPDATED_SCORE);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByScoreIsGreaterThanSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where score is greater than DEFAULT_SCORE
        defaultTemplateScoreRecordShouldNotBeFound("score.greaterThan=" + DEFAULT_SCORE);

        // Get all the templateScoreRecordList where score is greater than SMALLER_SCORE
        defaultTemplateScoreRecordShouldBeFound("score.greaterThan=" + SMALLER_SCORE);
    }


    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCreateUserIsEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where createUser equals to DEFAULT_CREATE_USER
        defaultTemplateScoreRecordShouldBeFound("createUser.equals=" + DEFAULT_CREATE_USER);

        // Get all the templateScoreRecordList where createUser equals to UPDATED_CREATE_USER
        defaultTemplateScoreRecordShouldNotBeFound("createUser.equals=" + UPDATED_CREATE_USER);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCreateUserIsNotEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where createUser not equals to DEFAULT_CREATE_USER
        defaultTemplateScoreRecordShouldNotBeFound("createUser.notEquals=" + DEFAULT_CREATE_USER);

        // Get all the templateScoreRecordList where createUser not equals to UPDATED_CREATE_USER
        defaultTemplateScoreRecordShouldBeFound("createUser.notEquals=" + UPDATED_CREATE_USER);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCreateUserIsInShouldWork() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where createUser in DEFAULT_CREATE_USER or UPDATED_CREATE_USER
        defaultTemplateScoreRecordShouldBeFound("createUser.in=" + DEFAULT_CREATE_USER + "," + UPDATED_CREATE_USER);

        // Get all the templateScoreRecordList where createUser equals to UPDATED_CREATE_USER
        defaultTemplateScoreRecordShouldNotBeFound("createUser.in=" + UPDATED_CREATE_USER);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCreateUserIsNullOrNotNull() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where createUser is not null
        defaultTemplateScoreRecordShouldBeFound("createUser.specified=true");

        // Get all the templateScoreRecordList where createUser is null
        defaultTemplateScoreRecordShouldNotBeFound("createUser.specified=false");
    }
                @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCreateUserContainsSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where createUser contains DEFAULT_CREATE_USER
        defaultTemplateScoreRecordShouldBeFound("createUser.contains=" + DEFAULT_CREATE_USER);

        // Get all the templateScoreRecordList where createUser contains UPDATED_CREATE_USER
        defaultTemplateScoreRecordShouldNotBeFound("createUser.contains=" + UPDATED_CREATE_USER);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCreateUserNotContainsSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where createUser does not contain DEFAULT_CREATE_USER
        defaultTemplateScoreRecordShouldNotBeFound("createUser.doesNotContain=" + DEFAULT_CREATE_USER);

        // Get all the templateScoreRecordList where createUser does not contain UPDATED_CREATE_USER
        defaultTemplateScoreRecordShouldBeFound("createUser.doesNotContain=" + UPDATED_CREATE_USER);
    }


    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCreateTimeIsEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where createTime equals to DEFAULT_CREATE_TIME
        defaultTemplateScoreRecordShouldBeFound("createTime.equals=" + DEFAULT_CREATE_TIME);

        // Get all the templateScoreRecordList where createTime equals to UPDATED_CREATE_TIME
        defaultTemplateScoreRecordShouldNotBeFound("createTime.equals=" + UPDATED_CREATE_TIME);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCreateTimeIsNotEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where createTime not equals to DEFAULT_CREATE_TIME
        defaultTemplateScoreRecordShouldNotBeFound("createTime.notEquals=" + DEFAULT_CREATE_TIME);

        // Get all the templateScoreRecordList where createTime not equals to UPDATED_CREATE_TIME
        defaultTemplateScoreRecordShouldBeFound("createTime.notEquals=" + UPDATED_CREATE_TIME);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCreateTimeIsInShouldWork() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where createTime in DEFAULT_CREATE_TIME or UPDATED_CREATE_TIME
        defaultTemplateScoreRecordShouldBeFound("createTime.in=" + DEFAULT_CREATE_TIME + "," + UPDATED_CREATE_TIME);

        // Get all the templateScoreRecordList where createTime equals to UPDATED_CREATE_TIME
        defaultTemplateScoreRecordShouldNotBeFound("createTime.in=" + UPDATED_CREATE_TIME);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCreateTimeIsNullOrNotNull() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where createTime is not null
        defaultTemplateScoreRecordShouldBeFound("createTime.specified=true");

        // Get all the templateScoreRecordList where createTime is null
        defaultTemplateScoreRecordShouldNotBeFound("createTime.specified=false");
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByOriginTypeIsEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where originType equals to DEFAULT_ORIGIN_TYPE
        defaultTemplateScoreRecordShouldBeFound("originType.equals=" + DEFAULT_ORIGIN_TYPE);

        // Get all the templateScoreRecordList where originType equals to UPDATED_ORIGIN_TYPE
        defaultTemplateScoreRecordShouldNotBeFound("originType.equals=" + UPDATED_ORIGIN_TYPE);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByOriginTypeIsNotEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where originType not equals to DEFAULT_ORIGIN_TYPE
        defaultTemplateScoreRecordShouldNotBeFound("originType.notEquals=" + DEFAULT_ORIGIN_TYPE);

        // Get all the templateScoreRecordList where originType not equals to UPDATED_ORIGIN_TYPE
        defaultTemplateScoreRecordShouldBeFound("originType.notEquals=" + UPDATED_ORIGIN_TYPE);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByOriginTypeIsInShouldWork() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where originType in DEFAULT_ORIGIN_TYPE or UPDATED_ORIGIN_TYPE
        defaultTemplateScoreRecordShouldBeFound("originType.in=" + DEFAULT_ORIGIN_TYPE + "," + UPDATED_ORIGIN_TYPE);

        // Get all the templateScoreRecordList where originType equals to UPDATED_ORIGIN_TYPE
        defaultTemplateScoreRecordShouldNotBeFound("originType.in=" + UPDATED_ORIGIN_TYPE);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByOriginTypeIsNullOrNotNull() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where originType is not null
        defaultTemplateScoreRecordShouldBeFound("originType.specified=true");

        // Get all the templateScoreRecordList where originType is null
        defaultTemplateScoreRecordShouldNotBeFound("originType.specified=false");
    }
                @Test
    @Transactional
    public void getAllTemplateScoreRecordsByOriginTypeContainsSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where originType contains DEFAULT_ORIGIN_TYPE
        defaultTemplateScoreRecordShouldBeFound("originType.contains=" + DEFAULT_ORIGIN_TYPE);

        // Get all the templateScoreRecordList where originType contains UPDATED_ORIGIN_TYPE
        defaultTemplateScoreRecordShouldNotBeFound("originType.contains=" + UPDATED_ORIGIN_TYPE);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByOriginTypeNotContainsSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where originType does not contain DEFAULT_ORIGIN_TYPE
        defaultTemplateScoreRecordShouldNotBeFound("originType.doesNotContain=" + DEFAULT_ORIGIN_TYPE);

        // Get all the templateScoreRecordList where originType does not contain UPDATED_ORIGIN_TYPE
        defaultTemplateScoreRecordShouldBeFound("originType.doesNotContain=" + UPDATED_ORIGIN_TYPE);
    }


    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCommentIsEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where comment equals to DEFAULT_COMMENT
        defaultTemplateScoreRecordShouldBeFound("comment.equals=" + DEFAULT_COMMENT);

        // Get all the templateScoreRecordList where comment equals to UPDATED_COMMENT
        defaultTemplateScoreRecordShouldNotBeFound("comment.equals=" + UPDATED_COMMENT);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCommentIsNotEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where comment not equals to DEFAULT_COMMENT
        defaultTemplateScoreRecordShouldNotBeFound("comment.notEquals=" + DEFAULT_COMMENT);

        // Get all the templateScoreRecordList where comment not equals to UPDATED_COMMENT
        defaultTemplateScoreRecordShouldBeFound("comment.notEquals=" + UPDATED_COMMENT);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCommentIsInShouldWork() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where comment in DEFAULT_COMMENT or UPDATED_COMMENT
        defaultTemplateScoreRecordShouldBeFound("comment.in=" + DEFAULT_COMMENT + "," + UPDATED_COMMENT);

        // Get all the templateScoreRecordList where comment equals to UPDATED_COMMENT
        defaultTemplateScoreRecordShouldNotBeFound("comment.in=" + UPDATED_COMMENT);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCommentIsNullOrNotNull() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where comment is not null
        defaultTemplateScoreRecordShouldBeFound("comment.specified=true");

        // Get all the templateScoreRecordList where comment is null
        defaultTemplateScoreRecordShouldNotBeFound("comment.specified=false");
    }
                @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCommentContainsSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where comment contains DEFAULT_COMMENT
        defaultTemplateScoreRecordShouldBeFound("comment.contains=" + DEFAULT_COMMENT);

        // Get all the templateScoreRecordList where comment contains UPDATED_COMMENT
        defaultTemplateScoreRecordShouldNotBeFound("comment.contains=" + UPDATED_COMMENT);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByCommentNotContainsSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where comment does not contain DEFAULT_COMMENT
        defaultTemplateScoreRecordShouldNotBeFound("comment.doesNotContain=" + DEFAULT_COMMENT);

        // Get all the templateScoreRecordList where comment does not contain UPDATED_COMMENT
        defaultTemplateScoreRecordShouldBeFound("comment.doesNotContain=" + UPDATED_COMMENT);
    }


    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTagsIsEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where tags equals to DEFAULT_TAGS
        defaultTemplateScoreRecordShouldBeFound("tags.equals=" + DEFAULT_TAGS);

        // Get all the templateScoreRecordList where tags equals to UPDATED_TAGS
        defaultTemplateScoreRecordShouldNotBeFound("tags.equals=" + UPDATED_TAGS);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTagsIsNotEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where tags not equals to DEFAULT_TAGS
        defaultTemplateScoreRecordShouldNotBeFound("tags.notEquals=" + DEFAULT_TAGS);

        // Get all the templateScoreRecordList where tags not equals to UPDATED_TAGS
        defaultTemplateScoreRecordShouldBeFound("tags.notEquals=" + UPDATED_TAGS);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTagsIsInShouldWork() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where tags in DEFAULT_TAGS or UPDATED_TAGS
        defaultTemplateScoreRecordShouldBeFound("tags.in=" + DEFAULT_TAGS + "," + UPDATED_TAGS);

        // Get all the templateScoreRecordList where tags equals to UPDATED_TAGS
        defaultTemplateScoreRecordShouldNotBeFound("tags.in=" + UPDATED_TAGS);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTagsIsNullOrNotNull() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where tags is not null
        defaultTemplateScoreRecordShouldBeFound("tags.specified=true");

        // Get all the templateScoreRecordList where tags is null
        defaultTemplateScoreRecordShouldNotBeFound("tags.specified=false");
    }
                @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTagsContainsSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where tags contains DEFAULT_TAGS
        defaultTemplateScoreRecordShouldBeFound("tags.contains=" + DEFAULT_TAGS);

        // Get all the templateScoreRecordList where tags contains UPDATED_TAGS
        defaultTemplateScoreRecordShouldNotBeFound("tags.contains=" + UPDATED_TAGS);
    }

    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTagsNotContainsSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        // Get all the templateScoreRecordList where tags does not contain DEFAULT_TAGS
        defaultTemplateScoreRecordShouldNotBeFound("tags.doesNotContain=" + DEFAULT_TAGS);

        // Get all the templateScoreRecordList where tags does not contain UPDATED_TAGS
        defaultTemplateScoreRecordShouldBeFound("tags.doesNotContain=" + UPDATED_TAGS);
    }


    @Test
    @Transactional
    public void getAllTemplateScoreRecordsByTemplateMarketIsEqualToSomething() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);
        TemplateMarket templateMarket = TemplateMarketResourceIT.createEntity(em);
        em.persist(templateMarket);
        em.flush();
        templateScoreRecord.setTemplateMarket(templateMarket);
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);
        Long templateMarketId = templateMarket.getId();

        // Get all the templateScoreRecordList where templateMarket equals to templateMarketId
        defaultTemplateScoreRecordShouldBeFound("templateMarketId.equals=" + templateMarketId);

        // Get all the templateScoreRecordList where templateMarket equals to templateMarketId + 1
        defaultTemplateScoreRecordShouldNotBeFound("templateMarketId.equals=" + (templateMarketId + 1));
    }

    /**
     * Executes the search, and checks that the default entity is returned.
     */
    private void defaultTemplateScoreRecordShouldBeFound(String filter) throws Exception {
        restTemplateScoreRecordMockMvc.perform(get("/api/template-score-records?sort=id,desc&" + filter))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$.[*].id").value(hasItem(templateScoreRecord.getId().intValue())))
            .andExpect(jsonPath("$.[*].recordId").value(hasItem(DEFAULT_RECORD_ID.intValue())))
            .andExpect(jsonPath("$.[*].templateId").value(hasItem(DEFAULT_TEMPLATE_ID.intValue())))
            .andExpect(jsonPath("$.[*].score").value(hasItem(DEFAULT_SCORE.doubleValue())))
            .andExpect(jsonPath("$.[*].createUser").value(hasItem(DEFAULT_CREATE_USER)))
            .andExpect(jsonPath("$.[*].createTime").value(hasItem(DEFAULT_CREATE_TIME.toString())))
            .andExpect(jsonPath("$.[*].originType").value(hasItem(DEFAULT_ORIGIN_TYPE)))
            .andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT)))
            .andExpect(jsonPath("$.[*].tags").value(hasItem(DEFAULT_TAGS)));

        // Check, that the count call also returns 1
        restTemplateScoreRecordMockMvc.perform(get("/api/template-score-records/count?sort=id,desc&" + filter))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(content().string("1"));
    }

    /**
     * Executes the search, and checks that the default entity is not returned.
     */
    private void defaultTemplateScoreRecordShouldNotBeFound(String filter) throws Exception {
        restTemplateScoreRecordMockMvc.perform(get("/api/template-score-records?sort=id,desc&" + filter))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$").isArray())
            .andExpect(jsonPath("$").isEmpty());

        // Check, that the count call also returns 0
        restTemplateScoreRecordMockMvc.perform(get("/api/template-score-records/count?sort=id,desc&" + filter))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(content().string("0"));
    }

    @Test
    @Transactional
    public void getNonExistingTemplateScoreRecord() throws Exception {
        // Get the templateScoreRecord
        restTemplateScoreRecordMockMvc.perform(get("/api/template-score-records/{id}", Long.MAX_VALUE))
            .andExpect(status().isNotFound());
    }

    @Test
    @Transactional
    public void updateTemplateScoreRecord() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        int databaseSizeBeforeUpdate = templateScoreRecordRepository.findAll().size();

        // Update the templateScoreRecord
        TemplateScoreRecord updatedTemplateScoreRecord = templateScoreRecordRepository.findById(templateScoreRecord.getId()).get();
        // Disconnect from session so that the updates on updatedTemplateScoreRecord are not directly saved in db
        em.detach(updatedTemplateScoreRecord);
        updatedTemplateScoreRecord
            .recordId(UPDATED_RECORD_ID)
            .templateId(UPDATED_TEMPLATE_ID)
            .score(UPDATED_SCORE)
            .createUser(UPDATED_CREATE_USER)
            .createTime(UPDATED_CREATE_TIME)
            .originType(UPDATED_ORIGIN_TYPE)
            .comment(UPDATED_COMMENT)
            .tags(UPDATED_TAGS);
        TemplateScoreRecordDTO templateScoreRecordDTO = templateScoreRecordMapper.toDto(updatedTemplateScoreRecord);

        restTemplateScoreRecordMockMvc.perform(put("/api/template-score-records").with(csrf())
            .contentType(MediaType.APPLICATION_JSON)
            .content(TestUtil.convertObjectToJsonBytes(templateScoreRecordDTO)))
            .andExpect(status().isOk());

        // Validate the TemplateScoreRecord in the database
        List<TemplateScoreRecord> templateScoreRecordList = templateScoreRecordRepository.findAll();
        assertThat(templateScoreRecordList).hasSize(databaseSizeBeforeUpdate);
        TemplateScoreRecord testTemplateScoreRecord = templateScoreRecordList.get(templateScoreRecordList.size() - 1);
        assertThat(testTemplateScoreRecord.getRecordId()).isEqualTo(UPDATED_RECORD_ID);
        assertThat(testTemplateScoreRecord.getTemplateId()).isEqualTo(UPDATED_TEMPLATE_ID);
        assertThat(testTemplateScoreRecord.getScore()).isEqualTo(UPDATED_SCORE);
        assertThat(testTemplateScoreRecord.getCreateUser()).isEqualTo(UPDATED_CREATE_USER);
        assertThat(testTemplateScoreRecord.getCreateTime()).isEqualTo(UPDATED_CREATE_TIME);
        assertThat(testTemplateScoreRecord.getOriginType()).isEqualTo(UPDATED_ORIGIN_TYPE);
        assertThat(testTemplateScoreRecord.getComment()).isEqualTo(UPDATED_COMMENT);
        assertThat(testTemplateScoreRecord.getTags()).isEqualTo(UPDATED_TAGS);
    }

    @Test
    @Transactional
    public void updateNonExistingTemplateScoreRecord() throws Exception {
        int databaseSizeBeforeUpdate = templateScoreRecordRepository.findAll().size();

        // Create the TemplateScoreRecord
        TemplateScoreRecordDTO templateScoreRecordDTO = templateScoreRecordMapper.toDto(templateScoreRecord);

        // If the entity doesn't have an ID, it will throw BadRequestAlertException
        restTemplateScoreRecordMockMvc.perform(put("/api/template-score-records").with(csrf())
            .contentType(MediaType.APPLICATION_JSON)
            .content(TestUtil.convertObjectToJsonBytes(templateScoreRecordDTO)))
            .andExpect(status().isBadRequest());

        // Validate the TemplateScoreRecord in the database
        List<TemplateScoreRecord> templateScoreRecordList = templateScoreRecordRepository.findAll();
        assertThat(templateScoreRecordList).hasSize(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    public void deleteTemplateScoreRecord() throws Exception {
        // Initialize the database
        templateScoreRecordRepository.saveAndFlush(templateScoreRecord);

        int databaseSizeBeforeDelete = templateScoreRecordRepository.findAll().size();

        // Delete the templateScoreRecord
        restTemplateScoreRecordMockMvc.perform(delete("/api/template-score-records/{id}", templateScoreRecord.getId()).with(csrf())
            .accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isNoContent());

        // Validate the database contains one less item
        List<TemplateScoreRecord> templateScoreRecordList = templateScoreRecordRepository.findAll();
        assertThat(templateScoreRecordList).hasSize(databaseSizeBeforeDelete - 1);
    }
}
